#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int money[4], peo;
    cin >> peo;
    for (int i=1; i<=3; ++i)
    {
        int num, price;
        cin >> num >> price;
        if (peo % num == 0) money[i] = peo/num*price;
        else money[i] = peo/num*price + price;
    }
    cout << *min_element(money+1, money+4);
    return 0;
}
